# -*- coding: utf-8 -*-
import sys
from Sqlite3Helper import Sqlite3Helper
#reload(sys)
#sys.setdefaultencoding('utf8')
text_factory = str
sql = Sqlite3Helper()
def add():
    a = raw_input("请输入关键异常点：")
    print a
    if len(a) < 1:
        print "异常点不能为空"
        raise AssertionError("没有输入异常点")

    b = raw_input("请输入问题原因：")
    print b
    if len(b) < 1:
        print "异原因不能为空"
        raise AssertionError("没有输入问题原因")
    author = raw_input("请输入贡献人姓名：")
    print author
    job_number = raw_input("请输入贡献人工号:")
    print job_number
    sql.addKeyPoint(a, b, author, job_number)

def queryByJobNum():
    a = raw_input("请输入工号：") + ""
    print a
    if len(a) < 1:
        raise AssertionError("工号不能为空")
    data = sql.queryKeyPointByJobNumber(a)
    print data
    for d in data:
        for dd in d:
            print dd

def delById():
    a = raw_input("请输入ID：") + ""
    print a
    if len(a) < 1:
        raise AssertionError("ID不能为空")
    sql.deleteKeyPointById(a)

l = len(sys.argv)
if l > 1:
    cmd = sys.argv[1]
    print cmd
    if cmd == "1":
        print "cmd = 1"
        queryByJobNum()
    elif cmd == "2":
        print "cmd = 2"
        add()
    elif cmd == "3":
        delById()




